import type { PageParam, PageResult, UploadInfo } from '#/api/base';

import { requestClient } from '#/api/request';

export namespace SystemApi {
  /** 岗位信息 */
  export interface System {
    id?: number;
    name: string;
    systemKey: string;
    url: string;
    images: UploadInfo[];
    systemDesc: string;
    image: string;
    loginCallbackUrl: string;
    handler: number;
    handlerName: string;
    createTime: string;
    updateTime: string;
  }
}

/** 查询系统列表 */
export function getSystemList(params: PageParam) {
  return requestClient.get<PageResult<SystemApi.System>>('/system/list', {
    params,
  });
}

/** 查询系统详情 */
export function getSystem(id: number) {
  return requestClient.get<SystemApi.System>(`/system/info?id=${id}`);
}

/** 新增系统 */
export function createSystem(data: SystemApi.System) {
  return requestClient.post('/system/create', data);
}

/** 修改系统 */
export function updateSystem(data: SystemApi.System) {
  return requestClient.put('/system/update', data);
}

/** 删除系统 */
export function deleteSystem(id: number) {
  return requestClient.delete(`/system/delete?id=${id}`);
}
